﻿#include "Page.h"

#include "Framework/Editor.h"

#include "Pages/EmptyAsset/EditorEmptyAssetPageModel.h"
#include "Pages/EmptyAsset/EditorEmptyAssetPageViewModel.h"
#include "Pages/EmptyAsset/EditorEmptyAssetPageView.h"

#include "Pages/Audio/EditorAudioPageModel.h"
#include "Pages/Audio/EditorAudioPageViewModel.h"
#include "Pages/Audio/EditorAudioPageView.h"

#include "Pages/Material/EditorMaterialPageModel.h"
#include "Pages/Material/EditorMaterialPageViewModel.h"
#include "Pages/Material/EditorMaterialPageView.h"

#include "Pages/Mesh/EditorMeshPageModel.h"
#include "Pages/Mesh/EditorMeshPageViewModel.h"
#include "Pages/Mesh/EditorMeshPageView.h"

#include "Pages/Scene/EditorScenePageModel.h"
#include "Pages/Scene/EditorScenePageViewModel.h"
#include "Pages/Scene/EditorScenePageView.h"

#include "Pages/Texture/EditorTexturePageModel.h"
#include "Pages/Texture/EditorTexturePageViewModel.h"
#include "Pages/Texture/EditorTexturePageView.h"

#include "Pages/Welcome/EditorWelcomePageModel.h"
#include "Pages/Welcome/EditorWelcomePageViewModel.h"
#include "Pages/Welcome/EditorWelcomePageView.h"

#include "Pages/TextFile/EditorTextFilePageModel.h"
#include "Pages/TextFile/EditorTextFilePageViewModel.h"
#include "Pages/TextFile/EditorTextFilePageView.h"

#include "Pages/Package/EditorPackagePageModel.h"  
#include "Pages/Package/EditorPackagePageViewModel.h"
#include "Pages/Package/EditorPackagePageView.h"

#include "Pages/CPUTimeAnalyze/EditorCPUTimeAnalyzePageViewModel.h"
#include "Pages/CPUTimeAnalyze/EditorCPUTimeAnalyzePageView.h"
#include "Pages/CPUTimeAnalyze/EditorCPUTimeAnalyzePageModel.h"

#include "Window/EditorWindowGroupModel.h"

void WHE::RegisterPageMVVM()
{
    auto Editor=REditor::Get();
    Editor->RegisterMVVM(
        REditorEmptyAssetPageModel::StaticClass()
        , REditorEmptyAssetPageViewModel::StaticClass()
        , REditorEmptyAssetPageView::StaticClass());

    Editor->RegisterMVVM(
        REditorAudioPageModel::StaticClass()
        , REditorAudioPageViewModel::StaticClass()
        , REditorAudioPageView::StaticClass());

    Editor->RegisterMVVM(
        REditorMaterialPageModel::StaticClass()
        , REditorMaterialPageViewModel::StaticClass()
        , REditorMaterialPageView::StaticClass());

    Editor->RegisterMVVM(
        REditorMeshPageModel::StaticClass()
        , REditorMeshPageViewModel::StaticClass()
        , REditorMeshPageView::StaticClass());

    Editor->RegisterMVVM(
        REditorScenePageModel::StaticClass()
        , REditorScenePageViewModel::StaticClass()
        , REditorScenePageView::StaticClass());

    Editor->RegisterMVVM(
        REditorTexturePageModel::StaticClass()
        , REditorTexturePageViewModel::StaticClass()
        , REditorTexturePageView::StaticClass());

    Editor->RegisterMVVM(
        REditorWelcomePageModel::StaticClass()
        , REditorWelcomePageViewModel::StaticClass()
        , REditorWelcomePageView::StaticClass());
    
    Editor->RegisterMVVM(
        REditorTextFilePageModel::StaticClass()
        , REditorTextFilePageViewModel::StaticClass()
        , REditorTextFilePageView::StaticClass());

    Editor->RegisterMVVM(
        REditorPackagePageModel::StaticClass()
        , REditorPackagePageViewModel::StaticClass()
        , REditorPackagePageView::StaticClass());

    Editor->RegisterMVVM(
        REditorCPUTimeAnalyzePageModel::StaticClass()
        , REditorCPUTimeAnalyzePageViewModel::StaticClass()
        , REditorCPUTimeAnalyzePageView::StaticClass());
}

void WHE::OpenWelcomePage()
{
    TScriptDelegate<TSharedObjectPtr<REditorPageModel>()> CreatePageMethod;
    CreatePageMethod.BindLambda([](){
        return NewObject<REditorWelcomePageModel>(REditorWindowGroupModel::Get());
    });

    REditorWindowGroupModel::Get()->OpenPage(
        REditorWelcomePageModel::GetPageIDStatic()
        ,CreatePageMethod
    );
}

void WHE::OpenPackageProjectPage()
{
    TScriptDelegate<TSharedObjectPtr<REditorPageModel>()> CreatePageMethod;
    CreatePageMethod.BindLambda([](){
        return NewObject<REditorPackagePageModel>(REditorWindowGroupModel::Get());
    });

    REditorWindowGroupModel::Get()->OpenPage(
        REditorPackagePageModel::GetPageIDStatic()
        ,CreatePageMethod
    );
}

void WHE::OpenCPUTimeAnalyzePage()
{
    TScriptDelegate<TSharedObjectPtr<REditorPageModel>()> CreatePageMethod;
    CreatePageMethod.BindLambda([](){
        return NewObject<REditorCPUTimeAnalyzePageModel>(REditorWindowGroupModel::Get());
    });

    REditorWindowGroupModel::Get()->OpenPage(
        REditorCPUTimeAnalyzePageModel::GetPageIDStatic()
        ,CreatePageMethod
    );
}
